package cn.ad.server.persistence.dao;

import cn.ad.server.domain.ad.DayTargert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface DayPartingDao {
	
	@Results(value={
		@Result(column = "id", property = "id", id = true),
		@Result(column="strategy_id", property="strategyId"),
		@Result(column="create_time", property="createTime"),
		@Result(column="update_time", property="updateTime")
	})
	@Select("select * from strategy_day_parting")
	List<DayTargert> findAll();
	
	@Results(value={
			@Result(column = "id", property = "id", id = true),
			@Result(column="strategy_id", property="strategyId"),
			@Result(column="create_time", property="createTime"),
			@Result(column="update_time", property="updateTime")
		})
	@Select("select * from strategy_day_parting where update_time >= #{value}")
	List<DayTargert> findAfterTime(String warmUpTime);
	
	@Results(value={
			@Result(column = "id", property = "id", id = true),
			@Result(column="strategy_id", property="strategyId"),
			@Result(column="create_time", property="createTime"),
			@Result(column="update_time", property="updateTime")
		})
	@Select("select * from strategy_day_parting where strategy_id = #{value}")
	DayTargert findByStrategyId(long sid);
	
	@Results(value={
			@Result(column = "id", property = "id", id = true),
			@Result(column="strategy_id", property="strategyId"),
			@Result(column="create_time", property="createTime"),
			@Result(column="update_time", property="updateTime")
		})
	@Select("select * from strategy_day_parting where strategy_id = #{value}")
	List<DayTargert> findAllByStrategyId(long sid);
	
	
	@Results(value={
			@Result(column = "id", property = "id", id = true),
			@Result(column="strategy_id", property="strategyId"),
			@Result(column="create_time", property="createTime"),
			@Result(column="update_time", property="updateTime")
		})
	@Select("select * from strategy_day_parting where strategy_id = #{id} and status = #{status}")
	List<DayTargert> selectAllByStrategyId(@Param("id")long id, @Param("status")int status);
	
	
}
	